<style>
	.priority_high{
		border-right: 3px solid rgb(255, 0, 0);
		width: 0px;
	}
	.priority_medium{
		border-right: 3px solid rgb(0, 204, 102);
		width: 0px;
	}
	.priority_low{
		border-right: 3px solid rgb(255, 255, 0);
		width: 0px;
	}
	.priority_none{
		background-color: #fff;
		width: 0px;
	}
	td div { position: relative; }
</style>

<div class="row-fluid">
<div class="span10">
<div class="row-fluid">
<header><i class="icon-info"></i> To Do<span class="pull-right">
 <span class="pull-right label"> <?php echo count($fav_todos) + count($todos); ?></span></header>
<?php 
//print_r($fav_todos)?>
<table class="table table-condensed table-bordered table-striped" id="prior">

<?php foreach($fav_todos as $fav_todo) {?>
<tr>
	<td width="3%" align="center" <?php if(($fav_todo->priority=="high")){echo 'class="priority_high"' ;}elseif(($fav_todo->priority=="medium")){echo 'class="priority_medium"';}elseif(($fav_todo ->priority=="low")){ echo 'class="priority_low"';}else{ echo 'class="priority_none"';} ?>>
					<?php if($fav_todo->is_completed == 0) {?>
					 <a href="<?php echo site_url('user/to_do/complete/'.$fav_todo->id.'/'.date('d').'/'.date('m').'/'.date('y'));?>"><i class="icon-ok-circle muted"></i></a></td>
					 <td width="87%" >
					 <a class="text-info"><?php echo $fav_todo->des?></a>
					 <?php }else {?>
					 <a href="<?php echo site_url('user/to_do/incomplete/'.$fav_todo->id);?>"><i class="icon-ok-sign text-success"></i>				
					 </a>
					 <?php echo $fav_todo->des?>
					 <?php }?>					 
				</td>	
	<td width="3%">			
					<a href="#" rel="<?php  echo site_url("user/to_do/rem_fav/".date('m')."/".date('y'))?>" onclick="rem_fav(<?php echo $fav_todo->id?>,<?php echo date('d');?>,this.rel)"><i class="icon-star"></i></a> 					
				</td>
				<td width="10%">
					<div class="dropdown">
  <a class="dropdown-toggle" data-toggle="dropdown" href="#"><i class="icon-cogs"></i>
  <b class="caret"></b>
  				</a>
					<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">						
						<?php if(!$this->ion_auth->is_admin($this->session->userdata('user_id'))){?> 
					 	<li><a href="<?php echo site_url('user/to_do/worksheet/'.$fav_todo->id);?>" class="add_worksheet"><i class="icon-plus text-error"></i> <span class="text-error"> Add To Worksheet</span> </a></li>
						<?php }?>
						<?php if($fav_todo->is_fav == 0){ ?>
						<li><a href="#" onclick="add_fav(<?php echo $fav_todo->id?>)"><i class="icon-star"></i> Add to Fav </a></li>
						<?php }?>
						<li><a href="<?php echo site_url('user/to_do/get_todo/'.$fav_todo->id);?>" class="get_todo"><i class="icon-edit"></i> Edit ToDo </a></li>	
						<li><a href="javascript:void(0)" onclick="delete_todo(<?php echo $fav_todo->id?>)"><i class="icon-trash"></i> Delete </a></li>
					 </ul>
					</div>
				</td>
</tr>
<?php }?>

<?php foreach($todos as $todo) {?>
<tr>
	<td width="3%" <?php if(($todo->priority=="high")){echo 'class="priority_high"' ;}elseif(($todo->priority=="medium")){echo 'class="priority_medium"';}elseif(($todo ->priority=="low")){ echo 'class="priority_low"';}else{ echo 'class="priority_none"';} ?>>
					<?php if($todo->is_completed == 0) {?>
					 <a href="<?php echo site_url('user/to_do/complete/'.$todo->id.'/'.date('d').'/'.date('m').'/'.date('y'));?>"><i class="icon-ok-circle muted"></i></a></td>
					 <?php }else {?>
					 <a href="<?php echo site_url('user/to_do/incomplete/'.$todo->id);?>"><i class="icon-ok-sign text-success"></i></a>
					 <?php }?>
					<td width="87%"> <span <?php if($todo->is_completed == 1) {?> style="text-decoration: line-through;" <?php } ?>><a class="text-info"><?php echo $todo->des;?></a></span>
				</td>
	<td width="3%">			
										
				</td>
	<td width="7%">
					<div class="dropdown">
  <a class="dropdown-toggle" data-toggle="dropdown" href="#"><i class="icon-cogs"></i>
  <b class="caret"></b>
  </a>
					<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
						
						<?php if(!$this->ion_auth->is_admin($this->session->userdata('user_id'))){?> 
					 	<li><a href="<?php echo site_url('user/to_do/worksheet/'.$todo->id);?>" class="add_worksheet"><i class="icon-plus text-error"></i> <span class="text-error"> Add To Worksheet</span> </a></li>
						<?php }?>
						<?php if($todo->is_fav == 0){ ?>
						<li><a href="javascript:void(0)" onclick="add_fav(<?php echo $todo->id?>)"><i class="icon-star"></i> Add to Fav </a></li>
						<?php }?>
						<li><a href="<?php echo site_url('user/to_do/get_todo/'.$todo->id);?>" class="get_todo"><i class="icon-edit"></i> Edit ToDo </a></li>	
						<li><a href="javascript:void(0)" onclick="delete_todo(<?php echo $todo->id?>)"><i class="icon-trash"></i> Delete </a></li>
					 </ul>
					</div>
					
					
						
					</td>
</tr>
<?php }?>
</table>
<div class="row-fluid" style="margin-top: -10px; margin-bottom: 10px;" >

<div class="span12">
<?php
	$z = 0;	
	foreach($more_todos as $td){
		$last_id = $td->id;			 
		$z++;} ?>
<div style="float: left" id="mores<?php if(!empty($last_id)){echo $last_id;}  ?>" class="moreboxes">

<a href="javascript:void(0)" class="mores" id="<?php if(!empty($last_id)){echo $last_id;}  ?>"><b>Load more..</b></a>

</div>

<div>
&nbsp;&nbsp;<a href="<?= site_url('user/to_do/view/'.$this->session->userdata('user_id').'/'.date('m').'/'.date('y'));?>" class="pull-right"><b>All Todo ..</b></a></div>
</div>
</div>
</div>

<div class="row-fluid">
<div class="span6">	
	<header>
	 <i class="icon-star text-info"></i> Fav Task 
	 <span class="pull-right label"> <?php echo count($fav_tasks); ?> </span>
	
	</header>
<table width="100%" class="table table-condensed table-bordered table-striped">
<tr>
<th>Title</th>
<th>Due Date</th>
<th>Priority</th>
<th>%</th>
</tr>
<?php foreach($fav_tasks as $fav_task) {?>
  <tr>
    <td>
    <a href="<?= site_url('user/tasks/task_detail').'/'.$fav_task->task_id;?>" data-placement="left" title="<?= $fav_task->name; ?>" class="text-info tooltips"><?= $fav_task->title;?></a></td>
    <td><?= $fav_task->end_date;?></td>
    <td><?= $fav_task->priority;?></td>
	<td><?= $fav_task->completed_percentage?></td>	
  </tr>  
  <?php }?>
</table>
<a href="<?= site_url('user/tasks');?>" class="pull-right">more..</a>
	
</div>
<div class="span6">	
	<header> <i class="icon-star text-error"></i> Fav Project
	<span class="pull-right label"> <?php echo count($fav_projects); ?> </span>
	</header>
	<table width="100%" class="table table-condensed table-bordered table-striped">
<tr>
<th>Title</th>
<th>Due Date</th>
<th>%</th>
</tr>
		<?php foreach($fav_projects as $fav_project) {?>
		 <tr>
    <td>
    <a href="<?php echo site_url('/user/tasks/milestones_details/'.$fav_project->id) ?>" class="text-info"><?= $fav_project->name;?></a></td>
    <td><?= $fav_project->end_date;?></td>
	<td><?php echo round($this->task_model->get_percentage_by_projectid($fav_project->id)).' %';?></td>
  </tr>
		<?php }?>
	</table>	
</div>
<a href="<?= site_url('user/tasks/my_projects');?>" class="pull-right">more..</a>
</div>

<div class="row-fluid">
<div class="span6">
<header>
<i class="icon-tasks"></i> Recent Task (s) <span class="pull-right"><i class="icon-cog"></i>&nbsp; </span>
</header>
<table class="table table-bordered table-condensed">
<tr>
<th>Title</th>
<th>Due Date</th>
<th>Priority</th>
<th>%</th>
</tr>
<?php foreach($recent_tasks as $recent_task){?>
<tr>
<td><a href="<?= site_url('user/tasks/task_detail').'/'.$recent_task->id;?>" data-placement="left" title="<?= $recent_task->name; ?>" class="tooltips"><?= $recent_task->title?></a></td>
<td><?= $recent_task->start_date?></td>
<td><?= $recent_task->priority?></td>
<td><?= $recent_task->completed_percentage?></td>

</tr>
<?php }?>
</table>
<div class="pull-right"><a href="<?= site_url('user/tasks');?>">more..</a></div>	
	
</div>
<div class="span6">
<header>
<i class="icon-tasks"></i> Recent Projects <span class="pull-right"><i class="icon-cog"></i>&nbsp; </span>
</header>
<table class="table table-bordered table-condensed">
<tr>
<th>Title</th>
<th>Due Date</th>
<th>%</th>
</tr>
<?php foreach($recent_project as $recent_project) {?>
		 <tr>
    <td>
    <a href="<?php echo site_url('/user/tasks/milestones_details/'.$recent_project->id) ?>" class="text-info"><?= $recent_project->name;?></a></td>
    <td><?= $recent_project->end_date;?></td>
	<td><?php echo round($this->task_model->get_percentage_by_projectid($recent_project->id)).' %';?></td>
  </tr>
		<?php }?>
</table>
<div class="pull-right"><a href="<?= site_url('user/tasks');?>">more..</a></div>	
</div>
</div>

</div>
<div class="span2">
<header><i class="icon-signal"></i> Online User Status</header>

<div class="online-status">
<strong>Active</strong>
<ul style="font-size:11px">
<?php foreach($active_user as $active_users) {
	if(($this->session->userdata('user_id')!= $active_users->id)){
	?>
<li class="text-success">
<a href="javascript:void(0)" onClick="javascript:chatWith('<?php echo $active_users->id;?>','<?php echo $active_users->username;?>') ">
<?= $active_users->username?>
</a>	
</li>
<?php }}?>
</ul>
<strong>InActive</strong>
<ul style="font-size:11px">
<?php foreach($inactive_user as $inactive_users) {?>
<li class="muted"><?= $inactive_users->username?>  - <?= date("h:i - d/m",$inactive_users->last_login)?></li>
<?php }?>
</ul>
</div>
</div>
</div>

<script type="text/javascript">

	function delete_todo(Id){									
		$.post('<?= site_url("user/to_do/delete");?>',{id:Id}, function(replies) {			
			location.reload();  		
	});
	}
	
	
	
$('.add_worksheet').click(function(event) {	
  event.preventDefault();
  $.get(this.href, function(html) {
  $(html).appendTo('body').modal(); 
  });
});
	
$('.get_todo').click(function(event) {	
  event.preventDefault();
  $.get(this.href, function(html) {
  $(html).appendTo('body').modal(); 
  });
});	

function add_fav(Id){	
	$.post('<?= site_url("user/to_do/add_fav");?>',{id:Id}, function(replies) {			
			location.reload();  		
	});
}

function rem_fav(Id,date_id){
	$.post('<?= site_url("user/to_do/rem_fav/$month_id/$year_id");?>',{id:Id,dateId:date_id}, function(replies) {			
			location.reload();  		
	});
}

$('.mores').live("click",function(){	
var ID = $(this).attr("id");
if(ID)
{	
$("#mores"+ID).html('<img src="<?php echo base_url()?>assets/images/7.gif" />');

$.post('<?= site_url("user/user/more_todos");?>',{id : ID}, function(data) {	
	$('#prior').append(data);
	$("#mores"+ID).remove();		
});
}else
{
$(".moreboxes").html('The End');
}
});

</script>
